home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MCASM.RAR / MC_ASM.EXE / WROX_ASM / CH12 / COMMON / GRAPH.H < prev    next >
C/C++ Source or Header  |  1994-09-21  |  4KB  |  185 lines

  1. // Structures and function declarations for dealing with graphics
  2. // Written by Yuri Kiselev, CZ 1994.
  3.  
  4. #ifndef GRAPH_H
  5. #define GRAPH_H
  6.  
  7. #include "common.h"
  8.  
  9. #define MAXLENGTHROW  2048
  10. #define MAXCOUNTROW 1024
  11.  
  12. typedef struct {
  13.     BYTE r,g,b;
  14.     } colortype;
  15. typedef colortype VGApalette[256];
  16.  
  17. typedef struct {
  18.     BYTE b,g,r;
  19.     } BGRcolortype;
  20. typedef BGRcolortype BGRpalette[256];
  21.  
  22. typedef BYTE rowtype[MAXLENGTHROW-1];
  23. typedef rowtype *rowptr;
  24. typedef rowptr imagetype[MAXCOUNTROW-1];
  25. typedef imagetype *imageptr;
  26.  
  27. typedef struct {
  28.     BYTE mode;
  29.     char name[20];
  30.     } modename;
  31.  
  32. typedef struct {
  33.     BYTE numberofmodes;
  34.     modename modes[20];
  35.     } modelisttype;
  36.  
  37. //coordinates of a point.
  38. typedef struct { int  x,y; } pointtype;
  39.  
  40. //viewport settings
  41. typedef struct {
  42.   int  left,top,right,bottom;
  43. } viewporttype;
  44.  
  45. //line settings
  46. typedef struct {
  47.    WORD linestyle;
  48.    WORD pattern;
  49.    BYTE width;
  50. } linesettingstype;
  51.  
  52. // Line Styles
  53. enum line_styles {
  54.     SOLID_LINE,
  55.     DOTTED_LINE,
  56.     CENTER_LINE,
  57.     DASHED_LINE,
  58.     USERBIT_LINE   // User defined line style
  59. };
  60.  
  61. // Line widths
  62. enum line_widths {
  63.     NORM_WIDTH = 1,
  64.     DOUBLE_WIDTH = 2,
  65.     THICK_WIDTH = 3,
  66. };
  67.  
  68. //Pascal's Fill Pattern Constants
  69.  
  70. //Fill patterns
  71. enum fill_patterns {
  72.     EMPTY_FILL,     // transparent
  73.     SOLID_FILL,     // fills area in solid fill color
  74.     LINE_FILL,      // --- fill
  75.     LTSLASH_FILL,   // /// fill
  76.     SLASH_FILL,     // /// fill with thick lines
  77.     BKSLASH_FILL,   // \\\ fill with thick lines
  78.     LTBKSLASH_FILL, // \\\ fill
  79.     HATCH_FILL,     // light hatch fill
  80.     XHATCH_FILL,    // heavy cross hatch fill
  81.     INTERLEAVE_FILL,// interleaving line fill
  82.     WIDE_DOT_FILL,  // Widely spaced dot fill
  83.     CLOSE_DOT_FILL, // Closely spaced dot fill
  84.     USER_FILL       // user defined fill
  85. };
  86.  
  87. #if !defined(__COLORS)
  88. #define __COLORS
  89.  
  90. enum coloros {
  91.     BLACK,          // dark colors
  92.     BLUE,
  93.     GREEN,
  94.     CYAN,
  95.     RED,
  96.     MAGENTA,
  97.     BROWN,
  98.     LIGHTGRAY,
  99.     DARKGRAY,           // light colors
  100.     LIGHTBLUE,
  101.     LIGHTGREEN,
  102.     LIGHTCYAN,
  103.     LIGHTRED,
  104.     LIGHTMAGENTA,
  105.     YELLOW,
  106.     WHITE
  107. };
  108. #endif
  109.  
  110. // Supported video modes
  111. // 16 colors(up to 800x600) - egavga16.asm
  112. // VGA 256 colors(320x200) - vga256.asm
  113. // SVGA 256 colors - svga256.asm
  114. // and so on.
  115. enum video_modes {
  116. // EGA & VGA standart(with 256k)
  117.     EGA16,
  118.     VGA16,
  119.     VGA256,
  120. // SVGA 256k
  121.     SVGA800x600x16,
  122.     SVGA640x400x256,
  123. // SVGA 512k
  124.     SVGA640x480x256,
  125.     SVGA800x600x256,
  126.     SVGA1024x768x16,
  127. // SVGA 1m
  128.     SVGA1024x768x256,
  129.     SVGA1280x1024x16,
  130. // SVGA 2m
  131.     SVGA1280x1024x256,
  132.     modecounter
  133. };
  134.  
  135. //
  136. enum put_method {
  137.     NORMAL_PUT,
  138.     XOR_PUT,
  139.     AND_PUT,
  140.     OR_PUT
  141. };
  142.  
  143. extern modelisttype modelist;
  144. extern BOOL drawpoly_in_fillpoly;
  145. // functions
  146. int graphinit(void);
  147. int switchmode(int mode);    // swithes the video modes
  148. void closegraph(void);
  149. void setviewport(int x1,int y1,int x2,int y2);
  150. void putpixel(int x,int y,BYTE color);
  151. BYTE getpixel(int x,int y);
  152. extern void (*line)(int x1,int y1,int x2,int y2);
  153. void getimage(int x1,int y1,int x2,int y2,void* buffer);
  154. void putimage(int xo,int yo,void* buffer);
  155. long imagesize(int x1,int Y1,int x2,int y2);
  156. void rectangle(int x1,int y1,int x2,int y2);
  157. void linerel(int dx,int dy);
  158. void lineto(int x,int y);
  159. void moveto(int x,int y);
  160. void moverel(int dx,int dy);
  161. int getmaxx(void);
  162. int getmaxy(void);
  163. void setcolor(BYTE color);
  164. BYTE getcolor(void);
  165. void setbkcolor(BYTE Color);
  166. void setlinestyle(WORD linestyle,WORD pattern,BYTE wline);
  167. void setfillstyle(BYTE pattern,BYTE color);
  168. void setfillpattern(BYTE* pattern);
  169. void setwritemode(BYTE wrmode);
  170. void setglassflag(BYTE glflag);
  171.  
  172. void bar(int x,int y,int x1,int y1);
  173. extern "C" void drawpoly(WORD numpoints,void* polypoints);
  174. extern "C" int fillpoly(WORD numpoints,void* polypoints);
  175.  
  176. void putrow(rowptr row,int x,int y,int xcount);
  177.  
  178. void ellipse(int xo,int yo,WORD xradius,WORD yradius);
  179. void circle(int x,int y,WORD radius);
  180.  
  181. extern "C" void setDACblock(BYTE first,WORD Count,void *far Pal);
  182. extern "C" void getDACblock(BYTE first,WORD Count,void *far Pal);
  183. extern "C" void setVGApalette(void *far Pal);
  184.  
  185. #endif